{extend name="template/base" /}
{block name="style"}
<link href="__LIB__/select2-4.0.3/dist/css/select2.min.css" rel="stylesheet" />
<link rel="stylesheet" href="__LIB__/webuploader/0.1.5/webuploader.css" />
<link rel="stylesheet" href="__LIB__/fontawesome-4.2.0_ie7/4.2.0/css/font-awesome.min.css" />
{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">派车单：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <select name="dispatch_group_id" class="select2"  id="dispatch_group_id">
                    {empty name = "vo['dispatch_group_id']"}
                    <option value="">选择派车单</option>
                    {/empty}
                    {volist name="dispatch_list" id="dispatch"}
                    <option value="{$dispatch['id']}" {if ($vo['dispatch_group_id'] == $dispatch['id'])} selected {/if}>{$dispatch['id']}：{$dispatch['realname']}【{$dispatch['title']}】</option>
                    {/volist}
                </select>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <table class="table table-border table-bordered table-hover table-bg mt-20">
            <thead>
            <tr class="text-c">
                <th width="">发票类型</th>
                <th width="">发票代码</th>
                <th width="">发票号码</th>
                <th width="">发票金额</th>
                <th width="">合计</th>
                <th width="">备注</th>
                <th width="">操作</th>
            </tr>
            </thead>
            <tbody id="tbody">
            <tr class="text-c">
<!--                <td><input type="text" class="input-text" placeholder="发票类型" name="traveler[invoice_type][]"></td>-->
                <td>
                    <select name="traveler[invoice_type][]" class="select">
                        <option value="">选择发票类型</option>
                        <option value="过路费">过路费</option>
                        <option value="加油费">加油费</option>
                        <option value="停车费">停车费</option>
                        <option value="洗车费">洗车费</option>
                        <option value="其他">其他</option>
                    </select>
                </td>
                <td><input type="text" class="input-text" placeholder="发票代码" name="traveler[invoice_code][]"></td>
                <td><input type="text" class="input-text" placeholder="发票号码" name="traveler[invoice_num][]"></td>
                <td><input type="text" class="input-text" placeholder="发票金额" name="traveler[invoice_money][]"></td>
                <td><input type="text" class="input-text" placeholder="合计" name="traveler[total][]"></td>
                <td><input type="text" class="input-text" placeholder="备注" name="traveler[remark][]"></td>
                <td><a href="javascript:" class="label label-success radius op-add" data-type="form"
                       onclick="deltd(this)" data-header="1">删除</a></td>
            </tr>
            </tbody>
        </table>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-primary radius ml-20" onclick="add()">&nbsp;&nbsp;增加&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="__LIB__/webuploader/0.1.5/webuploader.js"></script>
<script type="text/javascript" src="__LIB__/webuploader/0.1.5/image-upload/uploadimg.js"></script>
<script type="text/javascript" src="__LIB__/template/template.js"></script>
<!--select2 js 插件-->
<script type="text/javascript" src="__LIB__/select2-4.0.3/dist/js/select2.min.js"></script>
<script id="td" type="text/html">
    <tr class="text-c">
        <td>
            <select name="traveler[invoice_type][]" class="select">
                <option value="">选择发票类型</option>
                <option value="过路费">过路费</option>
                <option value="加油费">加油费</option>
                <option value="停车费">停车费</option>
                <option value="洗车费">洗车费</option>
                <option value="其他">其他</option>
            </select>
        </td>
        <td><input type="text" class="input-text" placeholder="发票代码" name="traveler[invoice_code][]"></td>
        <td><input type="text" class="input-text" placeholder="发票号码" name="traveler[invoice_num][]"></td>
        <td><input type="text" class="input-text" placeholder="发票金额" name="traveler[invoice_money][]"></td>
        <td><input type="text" class="input-text" placeholder="合计" name="traveler[total][]"></td>
        <td><input type="text" class="input-text" placeholder="备注" name="traveler[remark][]"></td>
        <td><a href="javascript:" class="label label-success radius op-add" data-type="form"
    onclick="deltd(this)" data-header="1">删除</a></td>
    </tr>
</script>
<script>
    // 新增一行添加记录
    function add() {
        html = template(document.getElementById('td').innerHTML, {});
        $("#tbody").append(html);
    }

    // 删除出行人员信息
    function deltd(ele) {
        $(ele).parent().parent().remove();
    }
    $(function () {

        upload_imgs("head_img");

        var id = $("#dispatch_group_id").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        {notempty name = "vo['dispatch_group_id']"}
        id.val("{$vo['dispatch_group_id']}").trigger("change");
        {/notempty}


        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                ajax_progress(ret);
            }
        });
    })
</script>
{/block}
